//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

import java.util.ArrayList;
import java.util.List;

public class demo_682 {
    public demo_682() {
    }

    public int calPoints(String[] operations) {
        List<Integer> val = new ArrayList();
        int con = 0;

        for(String operation : operations) {
            switch (operation) {
                case "C":
                    val.remove(val.size() - 1);
                    break;
                case "D":
                    val.add((Integer)val.get(val.size() - 1) * 2);
                    break;
                case "+":
                    val.add((Integer)val.get(val.size() - 1) + (Integer)val.get(val.size() - 2));
                    break;
                default:
                    val.add(Integer.parseInt(operation));
            }
        }

        for(Integer integer : val) {
            con += integer;
        }

        return con;
    }
}
